﻿#pragma once
#include "ctime"
#include "Windows.h"

namespace DYEngine
{
	class Time
	{
	public:
		Time() { }

		static void Init()
		{
			mFrameRate = 60;
			mFramePeriod = 1000L / mFrameRate;
			mGameTime = GetClock();
			mScale = 1;
			SetDeltaTime(mFramePeriod);
			mStartTime = clock();
		}

		// 获取真实时间
		static float GetRealTime();

		// 获取时钟，单位毫秒
		static long GetClock();

		// 获取游戏时间
		static float GetGameTime();

		/// <summary>
		/// 设置上一帧的耗时
		/// </summary>
		/// <param name="pDeltaTime"></param>
		static void SetDeltaTime(long pDeltaTime);

		/// <summary>
		/// 获取上一帧的耗时
		/// </summary>
		/// <returns></returns>
		static float GetDeltaTime();

		/// <summary>
		/// 设置帧率
		/// </summary>
		/// <param name="pFrameRate"></param>
		static void SetFrameRate(unsigned int pFrameRate);

		/// <summary>
		/// 获取帧率
		/// </summary>
		/// <returns></returns>
		static unsigned int GetFrameRate();

		static long GetFramePeriod();

		/// <summary>
		/// 设置游戏时间缩放
		/// </summary>
		/// <param name="pTimeScale"></param>
		static void SetTimeScale(float pTimeScale);

		/// <summary>
		/// 获取游戏时间的缩放
		/// </summary>
		/// <returns></returns>
		static float GetTimeScale();

		static void Update();
	public:
		static long mGameTime;
		static unsigned int mFrameRate;
		static long mFramePeriod;
		static float mDeltaTime;
		static float mScale;

		static float mStartTime;
	};
}
